package com.gxa.controller.set;

import com.gxa.common.R;
import com.gxa.entity.ContactManagement;
import com.gxa.service.ContactModeService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping("/dataDictionary/contactMod")
@Api(value = "接触方式管理的所有操作测试",tags = "接触方式管理接口API")
public class ContactModeController {

    @Autowired
    private ContactModeService contactModeService;

    /**
     * 添加接触方式
     * @param contactManagement
     * @return
     */
    @RequestMapping(value = "/addContactMode",method = RequestMethod.POST)
    @ApiOperation(value = "添加接触方式接口",notes = "添加接触方式信息",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=1001,message="要添加的接触方式已存在"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R addContactMode(@RequestBody @ApiParam(name = "contactManagement",value = "接触方式信息",required = true) ContactManagement contactManagement){
        return contactModeService.addContactMode(contactManagement);
    }

    /**
     * 修改接触方式
     * @param contactManagement
     * @return
     */
    @RequestMapping(value = "/updateContactMode",method = RequestMethod.POST)
    @ApiOperation(value = "修改接触方式接口",notes = "修改接触方式信息",httpMethod = "POST",response = R.class)
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R updateContactMode(@RequestBody @ApiParam(name = "contactManagement",value = "接触方式信息",required = true) ContactManagement contactManagement){
        return contactModeService.updateContactMode(contactManagement);
    }

    /**
     * 根据ID删除接触方式
     * @param id
     * @return
     */
    @RequestMapping(value = "/deleteContactMode",method = RequestMethod.POST)
    @ApiOperation(value = "删除接触方式接口",notes = "根据接触方式的编号删除接触方式信息",httpMethod = "POST",response = R.class)
    @ApiImplicitParam(name = "id",value = "要删除的接触方式编号",required = true,dataType = "int",paramType = "query")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R deleteContactMode(int id){
        return contactModeService.deleteContactMode(id);
    }

    /**
     * 分页查询所有接触方式
     * @return
     */
    @RequestMapping(value = "/queryAllContactModesByPage",method = RequestMethod.GET)
    @ApiOperation(value = "查询所有接触方式接口",notes = "查询所有接触方式进行分页显示",httpMethod = "GET",response = R.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage",value = "当前页码数",required = true,dataType = "int",paramType = "query"),
            @ApiImplicitParam(name = "pageSize",value = "每页显示记录数",required = true,dataType = "int",paramType = "query")
    })
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功"),
            @ApiResponse(code=404,message="找不到页面"),
            @ApiResponse(code=500,message="后台服务错误")
    })
    @ResponseBody
    public R queryAllContactModesByPage(int currentPage, int pageSize){
        return contactModeService.queryAllContactModesByPage(currentPage,pageSize);
    }
}
